<template>
	<view class="news-box">
		<view class="pic">
			<image :src="item.picurl" mode="aspectFill"></image>
		</view>
		<view class="text">
			<view class="title">
				<strong class="t">{{ item.title }}</strong>
			</view>
			<view class="info" v-if="!item.looktime">
				<text>{{ item.author }}</text>
				<text>{{ item.hits }}浏览</text>
			</view>
			<view class="info" v-else>
				<text>上次浏览时间：{{ item.looktime }}</text>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	name: 'news-box',
	props: {
		item: {
			type: Object,
			default() {
				return {
					title: '组件默认标题',
					author: '张三',
					hits: 668,
					picurl: '../../static/images/nopic.jpg',
				}
			},
		},
	},
	data() {
		return {}
	},
}
</script>

<style lang="scss" scoped>
.news-box {
	display: flex;
	.pic {
		width: 230rpx;
		height: 160rpx;
		image {
			width: 100%;
			height: 100%;
		}
	}
	.text {
		flex: 1;
		padding-left: 20rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		.title {
			font-size: 38rpx;
			color: #333;
			// 两行显示文字，超出变成...
			.t {
				overflow: hidden;
				text-overflow: ellipsis;
				display: -webkit-box;
				-webkit-box-orient: vertical;
				-webkit-line-clamp: 2;
			}
		}
		.info {
			font-size: 24rpx;
			color: #999;
			text:nth-child(2) {
				margin-left: 30rpx;
			}
		}
	}
}
</style>
